Repository navigation
fix(aggregator): Command Code quota reads use the latest dated plan read (#3410) - #3413
Conversation
…ead (#3410) extractCommandCode selected the first $X-of-$Y match in the section, so /api/quota.json rendered the stale 2026-10-25 dollar read as current: the freshest read (2026-10-27 console) is percentage-only and never matched. Per Drew's 2026-11-01 ruling, Command Code quota is the plan windows only (monthly limit, weekly, 5-hour) — never the top-up credit balance. - Segment the section at ISO date stamps and take the latest dated read, in the dollar format, the percentage-only console format, or its compact restatement. - A newer dated segment carrying a monthly figure no format can parse renders no windows instead of a stale read. - Regression tests pin latest-dated-read selection, the unparseable-freshest case, and balance-never-quota. - Verified against the live quota view: monthly 69%, weekly 14%, 5-hour 0% (the 2026-10-27 console read). Full aggregator suite 795 pass / 0 fail.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 35 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9522f98cc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // windows rather than presenting the older read as current (#3410). | ||
| const stale = segments.some( | ||
| (seg) => | ||
| seg.date > latest.date && |
There was a problem hiding this comment.
Reject stale reads when a later same-day observation is unparseable
When two observations share a date, a later unparseable monthly read does not invalidate the earlier parseable one because this comparison ignores the segment index used to break ties above. For example, a 2026-10-30 09:00 read containing monthly limit 55% used, followed by a 2026-10-30 12:00 read containing monthly limit 100 percent used, still reports 55% and a healthy pool instead of no current windows. Apply the same date/index ordering here so the fail-soft behavior also covers updates recorded on the same day.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 08e6438: the stale-read guard now uses the same (date, segment index) ordering as latest-read selection, so a later same-day unparseable monthly read invalidates the earlier parseable one. Pinned by a new regression test ("a later same-day unparseable read also invalidates the earlier one"); quota tests 51/51 pass.
Summary
Implements Drew's 2026-11-01 ruling (#3410) in
extractCommandCode(pm-stack/aggregator/src/quota-extract.ts): Command Code quota reads report the plan windows only — monthly limit, weekly, 5-hour — never the top-up credit balance.Before: the extractor took the first
$X of $Y usedmatch in the section, so/api/quota.jsonpresented the stale 2026-10-25 read ($6.57/$10, 5h 1.2%, weekly 8.8%) as current — the freshest read (2026-10-27 console: monthly 69%, weekly 14%, 5h 0%) is percentage-only and never matched.Now:
$X of $Y used+5h A%, weekly B%), percentage-only console (monthly limit N% used/weekly limit N%/5-hour limit N%), or its compact restatement (monthly N%, weekly N%, 5h N%).Evidence
test/quota.test.tspin: latest-dated-read selection across a multi-read section, the unparseable-freshest case, and balance-never-quota.bun test test/quota.test.ts test/quota-current.test.ts: 50 pass. Full aggregator suite: 795 pass / 0 fail.commandcode:gowindows = monthly 69%, weekly 14%, 5-hour 0% — the 2026-10-27 console read, as the acceptance requires.Queue task 5251 (repo-health-code-pilot). Closes #3410.
Need help on this PR? Tag
@codesmith-botwith what you need.